/**
 *  Copyright (c) Filipe Manana <fdmanana@gmail.com>
 *  All rights reserved.
 * 
 *  This file is part of jsdet.
 *
 *  jsdet is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published
 *  by the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  jsdet is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with jsdet.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


package jsdet.parsing.reporting;


import jsdet.parsing.GlobalParsingStats;

import java.util.*;


/**
 * 
 * @author Filipe Manana
 *
 */
public abstract class AbstractReporter implements Reporter {

    protected boolean reportFunctions = false;
    protected boolean reportClosureObjects = false;
    protected boolean reportInheritedMembers = false;
    protected boolean reportFileNames = false;
    protected Set<String> classesToFilter = null;
    protected String[] originalArgs = new String[0];
    protected boolean reportNamesOnly = false;
    protected Set<String> classesAlreadyReported = new HashSet<String>();
    protected ClassesSortOrder classesSortOrder = ClassesSortOrder.DEFAULT;


    public abstract void reportGlobalParsingStats(GlobalParsingStats stats);


    public String[] getOriginalArgs() {
        return originalArgs;
    }

    public void setOriginalArgs(String[] originalArgs) {
        this.originalArgs = originalArgs;
    }


    public void setReportFunctions(boolean reportFunctions) {
        this.reportFunctions = reportFunctions;
    }

    public boolean areFunctionsReported() {
        return reportFunctions;
    }

    public void setReportClosureObjects(boolean reportClosureObjects) {
        this.reportClosureObjects = reportClosureObjects;
    }

    public boolean areClosureObjectsReported() {
        return reportClosureObjects;
    }

    public void setReportInheritedMembers(boolean reportInheritedMembers) {
        this.reportInheritedMembers = reportInheritedMembers;
    }

    public boolean areInheritedMembersReported() {
        return reportInheritedMembers;
    }

    public void setReportFileNames(boolean reportFileNames) {
        this.reportFileNames = reportFileNames;
    }

    public boolean areFileNamesReported() {
        return reportFileNames;
    }

    public void setClassesToFilter(Set<String> classes) {
        classesToFilter = classes;
    }

    public Set<String> getClassesToFilter() {
        return classesToFilter;
    }

    public void setReportNamesOnly(boolean reportNamesOnly) {
        this.reportNamesOnly = reportNamesOnly;
    }

    public boolean getReportNamesOnly() {
        return reportNamesOnly;
    }

    public void setClassesSortOrder(Reporter.ClassesSortOrder order) {
        this.classesSortOrder = order;
    }

    public Reporter.ClassesSortOrder getClassesSortOrder() {
        return classesSortOrder;
    }

    protected boolean isClassInFilter(String className) {

        if ( (classesToFilter == null) || classesToFilter.isEmpty() ) {
            // all classes are to be reported
            return true;
        }

        return classesToFilter.contains(className);
    }
}
